<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * Ajax Delete File
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 01.10.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * class ajaxDeleteProperty
    ****
    * @package ajax
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 01.10.2005
    * @copyright essentialmind.com 2005
    ***/
    class ajaxDeleteProperty extends ajaxAction{

        public function process(){
            
            $propid = (int)$_REQUEST['id'];
            $nodeid = (int)$_REQUEST['node'];
            $pageid = (int)$_REQUEST['page'];
            
            $this->db->Execute("DELETE FROM properties WHERE id = $propid");
            $this->r->status = true;
            
            //figure out if there is an inheritance with dat
            $myTree = new tree($this->db,'structure LEFT JOIN objectmap ON (structure.id = objectmap.nodeid)',null,'id, url, level, title');
            $path   = $myTree->getPathStack($nodeid,true);
            
            $properties = array();
            $myProps    = array();
           
            //get the properties
            foreach($path as $key => $value){
                $properties = $this->db->getAssoc("SELECT name AS key, id, name, value FROM properties AS p, property_node_mapping AS pm WHERE p.name = '".$_REQUEST['tag']."' AND pm.propid = p.id AND pm.nodeid = $value[id]");    
                $myProps    = array_merge($myProps,$properties);
            }
            
            if(!empty($myProps)){
                $this->r->inherit = array_pop($myProps);
            }
        }
    }
?>